﻿using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using CID.Domain.Infrastructure;
using CID.Domain.Operations;
using CID.Execution.Support.Information;

namespace CID.Execution.Support.Scripting
{
    [DataContract]
    public abstract class ScriptStep
    {
        protected ScriptStep() { }

        protected ScriptStep(ITemplate template, IEnumerable<IParameterValue> parameterValues)
        {
            Template = new TemplateInfo(template);
            ParameterValues = parameterValues.Select(x => new ParameterValueInfo(x)).ToArray();
        }

        protected ScriptStep(ITemplate template, IEnumerable<IParameterValue> parameterValues, IEnumerable<IServer> targetServers)
        {
            Template = new TemplateInfo(template);
            ParameterValues = parameterValues.Select(x => new ParameterValueInfo(x)).ToArray();
            TargetServers = targetServers.Select(x => new ServerInfo(x)).ToArray();
        }

        [DataMember]
        public TemplateInfo Template { get; set; }

        [DataMember]
        public IEnumerable<ParameterValueInfo> ParameterValues { get; set; }

        [DataMember]
        public IEnumerable<ServerInfo> TargetServers { get; set; }
    }
}
